package com.qf.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.baseservice.impl.BaseServiceImpl;
import com.qf.entity.Order;
import com.qf.mapper.IOrderMapper;
import com.qf.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;

import java.sql.Wrapper;

/**
 * @Author：刘亚康
 * @Date：2020/4/12
 * @QQ：50770284
 * @Phone：18235947935
 * @Desc : 订单的实现类
 **/
@Service
public class OrderServiceImpl extends BaseServiceImpl<Order> implements IOrderService  {
    @Autowired
    private IOrderMapper orderMapper;

    @Override
    protected BaseMapper<Order> getBaseMapper() {
        return orderMapper;
    }

    /**
     * 更改订单状态
     *
     * @param out_trade_no
     * @param status
     * @return
     */
    @Override
    public int updateOrderStatus(String out_trade_no, int status) {
        Order order = orderMapper.selectById(out_trade_no);
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.set("order_state",status);
        int updateResult = orderMapper.update(order, wrapper);

        return updateResult;
    }
}
